<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('P_bn')}:</label>
        <div class="col-xs-12 col-sm-8">
            <a data-url="product_lists/products?status=radio" href="#"  class="btn btn-success btn-ajaxss"  data-title="选择产品" id="choose_product">选择产品</a>
            <input type="hidden" id="product" name="row[product]" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
        <div class="col-xs-12 col-sm-8">

            <div class="radio">
                {foreach name="statusList" item="vo"}
                <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label>
                {/foreach}
            </div>

        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('C_bn')}:</label>
        <div class="col-xs-12 col-sm-8">
            <a data-url="product_lists/products?status=check" href="#"  class="btn btn-success btn-ajaxs"  data-title="选择产品" id="choose_products">选择产品</a>
        </div>
    </div>
    <div class="form-group" style="overflow:scroll;">
    <table id="pro_table" class="table table-striped table-bordered table-hover table-nowrap">
        <thead>
            <tr>
                <th>操作</th>
                <th>产品编码</th>
                <th>产品名称</th>
                <th>产品规格</th>
                <th>单位</th>
                <th>重量</th>
                <th>颜色</th>
                <th>获取途径</th>
                <th>标准用量</th>
                <th>备注</th>
            </tr>
        </thead>
        <tbody id="MyPublishShow">

        </tbody>
    </table>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script>
    function delete_one(obj){
        var index = $(obj).parents("tr").index();
        $(obj).parents("tr").remove(); //实现删除tr
    }
    function edit_one(obj){
        var url = obj.getAttribute('data-url');
        if(!url) return false;
        var msg = obj.getAttribute('data-title');
        var width = obj.getAttribute('data-width');
        var height = obj.getAttribute('data-height');
        var area = ['80%', '80%'];
        var options = {
            shadeClose: false,
            shade: [0.3, '#393D49'],
            area: area,
            callback:function(value){
                if(value){
                    for (i = 0; i < value.length; i++) {
                        $("#MyPublishShow").append("<tr><td>" +
                                "<a href='#' onclick='delete_one(this);' id='"+value[i].bn+"' name='edit' class='btn btn-danger btn-del' ><i class='fa fa-trash'></i> 删除</a>"+
                                "</td><td>"+value[i].bn+
                                "</td><td>"+value[i].name+
                                "</td><td>"+value[i].spec+
                                "</td><td>"+"<input type='text' name='products["+value[i].bn+"][unit]' value='"+value[i].unit+"'>"+
                                "</td><td>"+value[i].access_text+
                                "</td><td>"+"<input type='text' name='products["+value[i].bn+"][Dosage]'>"+
                                "</td></tr>");
                    }

                }else{
                    Layer.alert('请选择一个产品');
                }
            }
        };
        parent.Fast.api.open(url,msg,options);
    }
</script>